/*
 * Copyright (C) 2010 Tetsuya Yasuda <tetsuyayasuda@gmail.com>
 */
package jp.tyas.libs.lisp;

public abstract class Context
{
    Context parent;

    public Context (Context parent)
    {
        this.parent = parent;
    }

    public abstract void set (Symbol sym);

    public abstract Symbol get (String name);

    public BlockContext findBlock (String name)
    {
        return parent == null ? null:
            parent.findBlock (name);
    }

    public Symbol find (String name)
    {
        Symbol res = get (name);
        if (res != null) return res;
        return parent == null ? null:
            parent.find (name);
    }

    public Context getToplevel ()
    {
        return parent == null ? this:
            parent.getToplevel();
    }
}
